{% extends "_base_lists.html" %}

{% block datagrid_initialize %}

	columns:[[
		{field:'selected', checkbox:true },
	    {field:'account_num',title:'额度账户',width:160, sortable:true,
			sorter:function(a,b){
				return (a>b?1:-1);
			}
		},
		{field:'name',title:'真实姓名',width:80},
		{field:'identify',title:'身份证号',width:120},
		{field:'balance',title:'账户余额',width:86},
		{field:'commissionRatio',title:'提成点数',width:39},
		{field:'accountType',title:'账户类型',width:39},
		{field:'parentidname',title:'直属上司',width:39},
		{field:'createtime',title:'创建时间',width:80},
		{field:'updatetime',title:'修改时间',width:80},

		{field:'action',title:'操作选项',width:78,
			formatter:function(value,row,index){
				if({{request.session.user.id}}==value || {{request.session.user.accountType}} == 2){
					return '<a onclick="javascript:return popUpEdit(this);" href="/lottery/accounts/edit/'+value+'">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="javascript:return message(this);" href="/lottery/accounts/mess/'+value+'">充值</a>';
				}else{
					return '-----&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="javascript:return message(this);" href="/lottery/accounts/mess/'+value+'">详细信息</a>';
				}
			}
		}
	]],
	{% endblock %}
	
	{% block datagrid_initialize22 %}

	columns:[[
		{field:'selected', checkbox:true },
	    {field:'account_num',title:'额度账户',width:160, sortable:true,
			sorter:function(a,b){
				return (a>b?1:-1);
			}
		},
		{field:'name',title:'真实姓名',width:80},
		{field:'identify',title:'身份证号',width:120},
		{field:'balance',title:'账户余额',width:86},
		{field:'commissionRatio',title:'提成点数',width:39},
		{field:'accountType',title:'账户类型',width:39},
		{field:'parentidname',title:'直属上司',width:39},
		{field:'createtime',title:'创建时间',width:80},
		{field:'updatetime',title:'修改时间',width:80},

		{field:'action',title:'操作选项',width:78,
			formatter:function(value,row,index){
				if({{request.session.user.id}}==value || {{request.session.user.accountType}} == 2){
					return '<a onclick="javascript:return popUpEdit(this);" href="/lottery/accounts/edit/'+value+'">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="javascript:return message(this);" href="/lottery/accounts/mess/'+value+'">详细信息</a>';
				}else{
					return '-----&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="javascript:return message(this);" href="/lottery/accounts/mess/'+value+'">详细信息</a>';
				}

			}
		}
	]],
	{% endblock %}
	
	{% block datagrid_initialize11 %}
	toolbar:[{

		id:'btnadd',
		text:'新增',
		iconCls:'icon-add',
		handler:function(){
		
			$.jBox("get:/lottery/accounts/add_ac",{
                 title: '新增额度账户',
                 width: 550,
                 height: 450,
                 top: '9%',
                 buttons: {},
                 loaded:function(){
 	            	
 	            }
           });
		}},'-',{
			id:'btndel',
			text:'删除',
			iconCls:'icon-cut',
			handler:deleteAccount
		}
	]
  {% endblock %}


{% block myscript %}
	function deleteAccount(){
		var postData = '';
		var rows = $('#{{datagrid_id}}').datagrid('getSelections');
		if(0 == rows.length) {
			$.jBox.error('请至少选择一条记录');
			return;
		}
		var msg = "";
		for(var i=0;i<rows.length;i++){
			cur_row = rows[i].name;
			msg += cur_row + "<br/>";
			postData += ('id=' + rows[i].action);
			postData += '&';
		}
		var message = '确定要删除以下账户？<br/>' + msg;
		
        $.jBox.confirm(message, "提示", function (v, h, f) {
            if (v == 'ok'){
            	$.ajax({
                    type:'POST',
                    url:'/lottery/accounts/deleteAccount',
                    data: postData,
                    success:function(data,status){
                    	$.jBox.tip('删除成功', 'success');
                    	$('#{{datagrid_id}}').datagrid('reload');
                    },
                    error:function (req, status, error){
                    	$.jBox.tip('删除失败', 'error');
                    }
                });
            }
            return true; //close
        });
       	return false;
	}
{% endblock %}

{% block search_menu %}
			<div name="identify" iconCls="icon-ok">身份证号</div>
			<div name="account" iconCls="icon-ok">额度账号</div>
			<div name="balance" iconCls="icon-ok">余额</div>
{% endblock %}
